package com.bifrost.repository;

import com.bifrost.entity.IndexSetting;
import com.bifrost.entity.IndexSettingRegion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;

/**
 *  @Author:Sophia
 *  @Date:2018/4/20
 *  
 */
public interface IndexSettingRepository extends JpaRepository<IndexSetting,Long>,JpaSpecificationExecutor<IndexSetting>{

    List<IndexSetting> findAllByIndexSettingRegion(IndexSettingRegion region);

    /**
     * 删除门店详细配置
     * @param settingIds
     */
    @Transactional
    @Modifying
    @Query(value = "DELETE FROM IndexSetting i WHERE indexSettingId in (?1)")
    void deleteByIndexSettingId(Collection settingIds);

    /**
     * 查询门店详细配置
     * @param indexSettingId
     * @param region
     * @return
     */
    IndexSetting findByIndexSettingIdAndIndexSettingRegion(Long indexSettingId, IndexSettingRegion region);

}
